package tests;

import tester.Example;
import tester.TestMethod;
import tester.Tester;
import tester.utilities.TesterUtility;
import tests.pojos.Address;
import tests.pojos.Person;

/**
 * @author w_jossey
 *
 */

@Example
public class ArrayTests {

	@TestMethod
	public void testArrayCloneSuccess(Tester t){
		int[] xArray = new int[10];
		xArray[0] = 1;
		xArray[1] = 5;
		int[] yArray = TesterUtility.objectCopy(xArray);
		t.checkExpect(xArray, yArray);

		Person[] pArray = new Person[10];
		pArray[0] = new Person("Wes", 23, new Address(203, "Boston Ave",
				"Medford", 2155, "MA"));
		pArray[1] = new Person("Weston Lee", 25, new Address(203,
				"Boston Ave", "Medford", 2154, "MA"));
		pArray[2] = new Person("Weston Lee Jossey", 26, new Address(203,
				"Boston Ave", "Medford", 2153, "MA"));
		Person[] pArrayClone = TesterUtility.objectCopy(pArray);
		Person[] pCopy = new Person[pArray.length];
		System.arraycopy(pArray, 0, pCopy, 0, pArray.length);

		t.checkExpect(pArray, pCopy);
		t.checkExpect(pArray, pArrayClone);
	}
	
	public void cloneFailureTestsArray(Tester t){

		int[] xArray = new int[10];
		xArray[0] = 1;
		xArray[1] = 5;
		int[] yArray = TesterUtility.objectCopy(xArray);
		xArray[2] = 7;
		t.checkExpect(xArray, yArray);

		Person[] pArray = new Person[10];
		pArray[0] = new Person("Wes", 23, new Address(203, "Boston Ave",
				"Medford", 2155, "MA"));
		pArray[1] = new Person("Weston Lee", 25, new Address(203,
				"Boston Ave", "Medford", 2154, "MA"));
		pArray[2] = new Person("Weston Lee Jossey", 26, new Address(203,
				"Boston Ave", "Medford", 2153, "MA"));
		Person[] pArrayClone = TesterUtility.objectCopy(pArray);
		pArray[0].setAge(1000000);
		t.checkExpect(pArray, pArrayClone);
	}
	
	public static void main(String[] args){
		Tester.runFullReport(new ArrayTests());
	}
	
}
